package yl.hs.bmipfull.service.report.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yl.hs.bmipfull.daos.finance.IShipSettleMainDao;
import yl.hs.bmipfull.service.report.IShipSettleMonthlyReportService;
import yl.hs.bmipfull.utils.VoUtil;
import yl.hs.bmipfull.viewmodels.PageQuery;
import yl.hs.bmipfull.viewmodels.PageResult;
import yl.hs.bmipfull.viewmodels.report.ShipSettleReportVO;
import yl.hs.bmipfull.viewmodels.salemanmage.SetTimeVO;
import yl.hs.bmipfull.viewmodels.salemanmage.TimeGroupVO;

import java.util.List;

/**
 * @author 张凯
 * @apiNote
 * @since 2022/3/4 10:13 上午 创建
 */
@Service
public class ShipSettleMonthlyReportServiceImpl implements IShipSettleMonthlyReportService {

    @Autowired
    IShipSettleMainDao settleMainDao;

    @Override
    public PageResult<ShipSettleReportVO> queryPage(PageQuery query, Integer page, Integer rowNum) {
        query.checkSortSides(ShipSettleReportVO.class);
        query.getQuery().put("querySkip",(page-1)*rowNum);
        query.getQuery().put("pageSize",rowNum);
        PageResult<ShipSettleReportVO> result=new PageResult(rowNum);
        result.setRecords(settleMainDao.queryCountReportPageVO(query.getQuery()));
        result.setPage(page);
        result.setData(settleMainDao.queryReportPageVO(query.getQuery()));
        return result;

    }

    @Override
    public List<TimeGroupVO> getSetTimeGroup() {
        List<SetTimeVO> setTime = settleMainDao.getSetTime();
        return VoUtil.groupTime(setTime);
    }
}
